package org.come.control;

import java.util.stream.Collectors;

import org.apache.commons.collections.CollectionUtils;
import org.come.action.FromServerAction;
import org.come.bean.RoleShow;
import org.come.until.GsonUtil;

import com.tool.image.ImageMixDeal;
import com.tool.image.ManimgAttribute;

public class UpRoleShowControl implements FromServerAction {
//	15841718789
	@Override
	public void controlMessFromServer(String mes, String type) {
		// 依据协议头进行划分方法
		RoleShow roleShow = GsonUtil.getGsonUtil().getgson().fromJson(mes, RoleShow.class);
		ManimgAttribute attribute=ImageMixDeal.huoquLogin(roleShow.getRolename());
		if (attribute!=null) {
			roleShow.setX(attribute.getRoleShow().getX());
			roleShow.setY(attribute.getRoleShow().getY());
			attribute.setRoleShow(roleShow);
			attribute.changeskin(null);
		}
		//宠物跟随
		if (CollectionUtils.isNotEmpty(roleShow.getShowRoleSummoningList())) {
			ImageMixDeal.petMap.put(roleShow.getRolename(),roleShow.getShowRoleSummoningList().stream().filter(e->e.isShow())
					.map(e->new ManimgAttribute(e,1)).collect(Collectors.toList()));
		}
	}

}
